package com.abo.yaas.view.widgets.validators;

import java.util.Date;

import com.vaadin.data.validator.AbstractValidator;

@SuppressWarnings("serial")
public class DateValidator extends AbstractValidator {

    public DateValidator(String errorMessage) {
        super(errorMessage);
    }

    @Override
    public boolean isValid(Object value) {
        if (!(value instanceof Date)) {
            return false;
        }
        final Date dateValue = Date.class.cast(value);
        return dateValue.getTime() - new Date().getTime() >= 72 * 60 * 60 * 1000;
    }
}
